//
//  Present.m
//  DebugDemo
//
//  Created by XFB on 2018/11/15.
//  Copyright © 2018年 ZhouCheng. All rights reserved.
//

#import "Present.h"
#import "Model.h"

@implementation Present

- (instancetype)init
{
    if (self = [super init]) {
        [self loadData];
    }
    return self;
}

- (void)loadData
{
    NSArray *tempArray = @[
                           @{@"name" : @"洫聙↘刀锋", @"imageURL" : @"https://www.baidu.com", @"count": @"1"},
                           @{@"name" : @"贫僧灬不虐人", @"imageURL" : @"https://www.baidu.com", @"count": @"2"},
                           @{@"name" : @"伟大旳苍穹", @"imageURL" : @"https://www.baidu.com", @"count": @"3"},
                           @{@"name" : @"绝辰冥天", @"imageURL" : @"https://www.baidu.com", @"count": @"4"},
                           @{@"name" : @"嗜魂龙吟", @"imageURL" : @"https://www.baidu.com", @"count": @"5"},
                           @{@"name" : @"乱世之巅", @"imageURL" : @"https://www.baidu.com", @"count": @"6"},
                           @{@"name" : @"不灭红神", @"imageURL" : @"https://www.baidu.com", @"count": @"7"},
                           @{@"name" : @"血战苍穹", @"imageURL" : @"https://www.baidu.com", @"count": @"8"},
                           @{@"name" : @"瞬灭天下", @"imageURL" : @"https://www.baidu.com", @"count": @"9"},
                           @{@"name" : @"血战メ傲神", @"imageURL" : @"https://www.baidu.com", @"count": @"9"},
                           @{@"name" : @"傲视判决", @"imageURL" : @"https://www.baidu.com", @"count": @"9"},
                           @{@"name" : @"一世霸主", @"imageURL" : @"https://www.baidu.com", @"count": @"9"},
                           @{@"name" : @"嗜血狱王", @"imageURL" : @"https://www.baidu.com", @"count": @"9"},
                           @{@"name" : @"孤影月下", @"imageURL" : @"https://www.baidu.com", @"count": @"9"},
                           @{@"name" : @"恨天幽狼", @"imageURL" : @"https://www.baidu.com", @"count": @"9"},
                           ];
    
    /// 添加数据模型
    for (NSInteger i = 0; i < tempArray.count; i ++) {
        Model *model = [Model initModelWithDictionary:tempArray[i]];
        [self.dataArray addObject:model];
    }
}

- (NSMutableArray *)dataArray
{
    if (_dataArray == nil) {
        _dataArray = @[].mutableCopy;
    }
    return _dataArray;
}


#pragma mark --- <PresentDelegate>
- (void)minusAndPlusButtonDidClickWithCount:(NSString *)count indexPath:(NSIndexPath *)indexPath
{
    for (NSInteger i = 0; i < self.dataArray.count; i ++) {
        if (i == indexPath.row) {
            Model *model = self.dataArray[indexPath.row];
            model.count = count;
            break;
        }
    }
}

@end
